home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / nt / emacssrc.zip / EMACSSRC.TAR / emacs-19.17 / src / mem-limits.h < prev    next >
C/C++ Source or Header  |  1993-11-20  |  3KB  |  148 lines

  1. /* Includes for memory limit warnings.
  2.    Copyright (C) 1990, 1993 Free Software Foundation, Inc.
  3.  
  4. This file is part of GNU Emacs.
  5.  
  6. GNU Emacs is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2, or (at your option)
  9. any later version.
  10.  
  11. GNU Emacs is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GNU Emacs; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. #if defined(__osf__) && (defined(__mips) || defined(mips))
  21. #include <sys/time.h>
  22. #include <sys/resource.h>
  23. #endif
  24.  
  25. #ifdef __bsdi__
  26. #define BSD4_2
  27. #endif
  28.  
  29. #ifdef WINDOWSNT
  30. #define LIM_DATA    0
  31. #define vlimit(_arg1, _arg2)    0
  32. #else /* !WINDOWSNT */
  33. #ifndef BSD4_2
  34. #ifndef USG
  35. #include <sys/vlimit.h>
  36. #endif /* not USG */
  37. #else /* if BSD4_2 */
  38. #include <sys/time.h>
  39. #include <sys/resource.h>
  40. #endif /* BSD4_2 */
  41. #endif /* !WINDOWSNT */
  42.  
  43. #ifdef emacs
  44. /* The important properties of this type are that 1) it's a pointer, and
  45.    2) arithmetic on it should work as if the size of the object pointed
  46.    to has a size of 1.  */
  47. #ifdef __STDC__
  48. typedef void *POINTER;
  49. #else
  50. typedef char *POINTER;
  51. #endif
  52.  
  53. typedef unsigned long SIZE;
  54.  
  55. #ifdef NULL
  56. #undef NULL
  57. #endif
  58. #define NULL ((POINTER) 0)
  59.  
  60. extern POINTER start_of_data ();
  61. #ifdef DATA_SEG_BITS
  62. #define EXCEEDS_LISP_PTR(ptr) \
  63.   (((unsigned int) (ptr) & ~DATA_SEG_BITS) >> VALBITS)
  64. #else
  65. #define EXCEEDS_LISP_PTR(ptr) ((unsigned int) (ptr) >> VALBITS)
  66. #endif
  67.  
  68. #ifdef BSD
  69. #ifndef DATA_SEG_BITS
  70. extern char etext;
  71. #define start_of_data() &etext
  72. #endif
  73. #endif
  74.  
  75. #else  /* Not emacs */ 
  76. extern char etext;
  77. #define start_of_data() &etext
  78. #endif /* Not emacs */
  79.  
  80.   
  81.  
  82. /* start of data space; can be changed by calling malloc_init */
  83. static POINTER data_space_start;
  84.  
  85. /* Number of bytes of writable memory we can expect to be able to get */
  86. static unsigned int lim_data;
  87.  
  88. #ifdef USG
  89.  
  90. static void
  91. get_lim_data ()
  92. {
  93.   extern long ulimit ();
  94.  
  95.   lim_data = -1;
  96.  
  97.   /* Use the ulimit call, if we seem to have it.  */
  98. #if !defined (ULIMIT_BREAK_VALUE) || defined (LINUX)
  99.   lim_data = ulimit (3, 0);
  100. #endif
  101.  
  102.   /* If that didn't work, just use the macro's value.  */
  103. #ifdef ULIMIT_BREAK_VALUE
  104.   if (lim_data == -1)
  105.     lim_data = ULIMIT_BREAK_VALUE;
  106. #endif
  107.  
  108.   lim_data -= (long) data_space_start;
  109. }
  110.  
  111. #else /* not USG */
  112. #ifdef WINDOWSNT
  113.  
  114. static void
  115. get_lim_data ()
  116. {
  117.     extern unsigned long DataRegionSize;
  118.     lim_data = DataRegionSize;
  119. }
  120.  
  121. #else
  122. #if !defined(BSD4_2) && !defined(__osf__)
  123.  
  124. static void
  125. get_lim_data ()
  126. {
  127.   lim_data = vlimit (LIM_DATA, -1);
  128. }
  129.  
  130. #else  /* BSD4_2 */
  131.  
  132. static void
  133. get_lim_data ()
  134. {
  135.   struct rlimit XXrlimit;
  136.  
  137.   getrlimit (RLIMIT_DATA, &XXrlimit);
  138. #ifdef RLIM_INFINITY
  139.   lim_data = XXrlimit.rlim_cur & RLIM_INFINITY; /* soft limit */
  140. #else
  141.   lim_data = XXrlimit.rlim_cur;    /* soft limit */
  142. #endif
  143. }
  144.  
  145. #endif /* BSD4_2 */
  146. #endif /* !WINDOWSNT */
  147. #endif /* not USG */
  148.